<?php

class commDbResourceBase extends commDbResourceAbstract
{
    private static $resource;

    public static function resource($db, $type)
    {
        parent::resource($db, $type);

        $instance = new self($db, $type);

        return $instance->getDsn();
    }

    public function getDsn()
    {
        $this->getLoadDatabaseIni();
        $aDsn = $this->getFindResoure();

        return ($this->type == 'pdo') ? $this->setDnsForPDO($aDsn) : $this->setDsnForMDB($aDsn);
    }

    private function getLoadDatabaseIni()
    {
        if (empty(self::$resource)) {
            //require_once(SC_DIR_LIB.'/inc/inc.database.mdb.php');
            require_once(SC_DIR_LIB."/config/app/app.db.mdb.php");

            self::$resource = $aDatabase;
        }
    }

    private function getFindResoure()
    {
        if (!empty(self::$resource[$this->db])) {
            return self::$resource[$this->db];
        }

        if (empty($aDatabase)) {
            throw new exceptionDb('DB 연결 정보가 없습니다.');
        }

        return $aDatabase[$this->db];
    }
}